﻿using NHibernate;
using MiserDB.MySql;
using NHibernate.Criterion;
using System.Collections.Generic;

namespace MiserDB.DataHelp
{
    public class PersonHelper : A_DataHelper
    {
        public T VerifyData<T>(string username, string pwd) where T : class
        {
            IList<T> list = Session.CreateCriteria<T>().Add(Restrictions.Eq("Name", username))
                   .Add(Restrictions.Eq("Pwd", pwd)).List<T>();
            if (list != null && list.Count == 1) return list[0];

            return null;
        }

        public T GetData<T>(int uid) where T : class
        {
            T p = Session.Get<T>(uid);
            Session.Flush();
            return p;
        }
    }
}
